package {
	import mz.behaveas.model.expectation.EqualExpectation;
	import mz.behaveas.model.expectation.Expectation;
	import mz.behaveas.model.expectation.ExpectationFactory;
	import mz.behaveas.model.expectation.IgnoredExpectation;
	import mz.behaveas.model.expectation.MallformedExpectation;
	import mz.behaveas.model.expectation.NotEqualExpectation;
	import mz.behaveas.model.expectation.NotImplementedExpectation;
	import mz.behaveas.model.expectation.ThrowExpectation;
	import mz.behaveas.model.ducktype.Duck;
	
/**
 * @author maxim.zaks@gmail.com
 */
public const ExpectationFactorySpec : * = {
		description: "This spec describes the behaviour of ExpectationFactory class.",
		expectations:[
			{
				description : "Create expectation without description",
				behaviour : function():*{
						return ExpectationFactory.createExpectation({shouldEqual:"hallo"});
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Create expectation only with description", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo"});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:NotImplementedExpectation, description:'hallo'})
			},
			{
				description : "Create expectation with not string description", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:20});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Create ignored expectation", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", ignore:"feature is not implemented yet"});
					return exp;
				},
				shouldEqual : new Duck({_type_:IgnoredExpectation})	
			},
			{
				description : "Create expectation with not Function as behaviour", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:20});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Create expectation with Function as behaviour but no should", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():void {}});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Create equal expectation with true value and no behaviour", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", shouldEqual:true});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:NotImplementedExpectation})
			},
			{
				description : "Create equal expectation with true value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldEqual:true});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:EqualExpectation})
			},
			{
				description : "Create not equal expectation with true value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldNotEqual:true});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:NotEqualExpectation})
			},
			{
				description : "Create not equal expectation with null value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldNotEqual:null});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:NotEqualExpectation})
			},
			{
				description : "Create throw expectation with Error value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldThrow:Error});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:ThrowExpectation})
			},
			{
				description : "Create throw expectation with Duck value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldThrow:new Duck({_type_:Error})});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:ThrowExpectation})
			},
			{
				description : "Create throw expectation with bad value", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", behaviour:function():* {}, shouldThrow:123});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Expectation is malformed if created with equal, not equal and throw", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", shouldEqual:123, shouldNotEqual:"", shouldThrow:Error});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Expectation is malformed if created with equal and not equal", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", shouldEqual:123, shouldNotEqual:""});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Expectation is malformed if created with equal and throw", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", shouldEqual:123, shouldThrow:Error});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			},
			{
				description : "Expectation is malformed if created with not equal and throw", 
				behaviour : function():* {
					var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo", shouldNotEqual:123, shouldThrow:Error});
					return exp;
				}, 
				shouldEqual:new Duck({_type_:MallformedExpectation})
			}
		]
	};
}
